﻿/*********************************************************************
 *
 *                             NOTICE
 *               COPYRIGHT (c) 2012 Panoscopix Software, Inc.
 *                UNPUBLISHED - ALL RIGHTS RESERVED
 * 
 *      This program is confidential, proprietary, and a trade
 *   secret of Panoscopix Software, Inc. The receipt or possession of
 *     this program does not convey any rights to reproduce or
 *      disclose its contents, or to manufacture, use, or sell
 *       anything that it may describe, in whole or in part, 
 *   without the specific written consent of Panoscopix Software, Inc.
 *
 * Utility to emulate the .net Class Loader static initialization
 * 
 *******************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace FileSystem.Utility
{
    class ClassLoaderUtil
    {
        public static void forceStaticInitialization() {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Type[] types = assembly.GetTypes();
            //ConsoleOutUtil.println("LOADER:  Have " + types.Length + " types.");
            for (int i = 0; i < types.Length; i++) {
                //ConsoleOutUtil.println("LOADER:  Type " + i + " = " + types[i].FullName);
                MethodInfo method = types[i].GetMethod("loadEmulator", BindingFlags.Static | BindingFlags.NonPublic);
                if (null != method) {
                    //ConsoleOutUtil.println("LOADER:  Found method for type " + types[i].FullName);
                    types[i].InvokeMember("loadEmulator", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, null);
                }
            }
        }
    }
}
